<?php
$pageTitle = "提交反馈";
$currentPage = "feedback";
include('../resource/navbar.php');
include('../resource/db/db.php');
if (!isset($_COOKIE['user_id'])) {
    header("Location: ../main/login.php");
    exit();
}

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $user_id = $_COOKIE['user_id'];
    $content = $_POST['content'];

    $sql = "INSERT INTO feedback (user_id, content) VALUES ('$user_id', '$content')";

    if ($conn->query($sql) === TRUE) {
        echo "反馈提交成功！";
        header("Location: center.php");
    } else {
        echo "Error: " . $sql . "<br>" . $conn->error;
    }

    $conn->close();
}
?>

<!DOCTYPE html>
<html>

<head>
    <title>提交反馈</title>
    <link rel="stylesheet" href="../resource/css/styles.css">
</head>

<body>
    <div class="container">
        <h2>提交反馈</h2>
        <form method="post" action="">
            反馈内容: <textarea name="content" required></textarea><br>
            <input type="submit" value="提交">
        </form>
    </div>
</body>

</html>